COMPILE_OPT

The COMPILE_OPT statement allows you to give the IDL compiler information that changes some of the default rules for compiling the function or procedure within which the COMPILE_OPT statement appears.

In all new code we recommend the use of:

COMPILE_OPT IDL3

We further recommend the use of:

COMPILE_OPT IDL3, HIDDEN

in routines that are not intended to be called directly by users (for example, helper routines that are part of a larger package).

Syntax

COMPILE_OPT opt1 [, opt2, ..., optn]

Arguments

optn

This argument can be any of the following:

COMPILE_OPT DEFINT32, STRICTARR

COMPILE_OPT DEFINT32, FLOAT64, LOGICAL_PREDICATE, STRICTARR

A side-effect of making a routine hidden is that IDL will not print a “Compile module” message for it when it is compiled from the library to satisfy a call to it. This makes hidden routines appear built-in to the user.

A predicate expression is an expression that is evaluated as being “true” or “false” as part of a statement that controls program execution. IDL evaluates such expressions in the following contexts:

IF...THEN...ELSE statements

? : inline conditional expressions

WHILE...DO statements

REPEAT...UNTIL statements

– The result from an object's INIT method to determine if the object was successfully created

By default, IDL uses the following rules to determine whether an expression is true or false:

Integer: An integer is considered true if its least significant bit is 1, and false otherwise. Hence, odd integers are true and even integers (including zero) are false. This interpretation of integer truth values is sometimes referred to as “bitwise,” reflecting the fact that the value of the least significant bit determines the result.

Other: Non-integer numeric types are true if they are non-zero, and false otherwise. String and heap variables (pointers and object references) are true if they are non-NULL, and false otherwise.

When LOGICAL_PREDICATE is set, IDL uses the following rules to determine whether an expression is true or false:

All Types: A number is considered true if its value is non-zero, and false otherwise. String and heap variables (pointers and object references) are true if they are non-NULL, and false otherwise.

Note: IDL's NOT operator is a bitwise operator (1’s complement), and is generally unsuitable for predicate expressions. For example:

WHILE (NOT EOF(lun)) DO ...

The EOF function returns 1 when it reaches the end of file. However, the expression "NOT 1" has the numeric value –2. When LOGICAL_PREDICATE is not in use, the WHILE statement sees –2 as false and the loop will terminate; if LOGICAL_PREDICATE is in use, –2 is a true value and the above loop will never terminate. Instead, you should use the ~ logical negation operator:

WHILE (~EOF(lun)) DO ...

This version will work properly regardless of the LOGICAL_PREDICATE setting.

Note: STRICTARR has no effect on the use of parentheses to reference structure tags using the tag index, since this is not an array indexing operation. For example, no syntax error will occur when compiling the following code:

COMPILE_OPT STRICTARR

mystruct = {a:0, b:1}

print, mystruct.(0)

Version History

5.3

Introduced

5.6

Added STRICTARRSUBS option

6.0

Added LOGICAL_PREDICATE option

8.3 Added STATIC option

8.4

Added NOSAVE option
8.9 Added FLOAT64 and IDL3 options